package com.hangxintong.common.utils;

import com.hangxintong.common.exception.ErrorInfo;

/**
 * @author zxkj
 */
public class EnumUtil {

    public static <T extends ErrorInfo> T getByCode(String code, Class<T> enumClass) {
        for (T each: enumClass.getEnumConstants()) {
            if (code.equals(each.getErrorCode())) {
                return each;
            }
        }
        return null;
    }
}
